package com.hnevc.androiduiclassone4;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * Created by Administrator on 2018/6/6.
 */

public class MyDialog extends Dialog {
    EditText etName ;
    Context context;
    public MyDialog(@NonNull Context context) {
        super(context);
        this.context =context;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_dialog);//绑定布局文件
        etName = findViewById(R.id.et_name);//获取控件
        Button btnOK = findViewById(R.id.btn_OK);
        btnOK.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(context, etName.getText().toString(), Toast.LENGTH_SHORT).show();
                dismiss();
            }
        });

    }
}
